package ProjectXXX;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.TitledBorder;
import javax.swing.GroupLayout;


public class PrintReportPanel extends JPanel
{
	//attributes
	private JPanel basePanel = null,southBasePanel = null,centerBasePanel = null,
	               reportChoosePanel = null,reportPanel = null,
	               generalPanel = null,DatePanel = null;;
	               
	private JTextField fromDateJTF = null,toDateJTF = null;
	private JButton fromDateBut = null,toDateBut = null;
	
	private JCheckBox dailySummaryCB = null,totalRentalsCB = null;   
	private ButtonGroup generalBG;
	
	private JCheckBox topTenRentalsCB = null, topTenCustomerCB = null,oldStockCB = null;
	private ButtonGroup specifiedBG = null;      
	               
	private JButton displayBut = null,printBut = null;
              
    private JLabel reportPanelLabel = null;           
               
	private JLabel pageLabel = null,
	               dailySumLabel = null, totalRentsLabel = null,
	               topTenRLabel = null,topTenCustLabel = null,oldStockLabel = null,
	               custTestLabel = null,customLabel = null;
	                             
	
	private JTextArea reportJTA = null;
	private JScrollPane jsp = null;
	
	private JComboBox jcb1 = null,jcb2 = null,jcb3 = null;
	private JLabel jcbLabel1 = null,jcbLabel2 = null,jcbLabel3 = null;
	
	private JFrame testFrame;
	
	//colours & FOnts
	private Font butFont;
	private Font mainLabelFont;
	private Color customColour;
	
	//constructor
	public PrintReportPanel()
	{
	    //colours & fonts
	    butFont = new Font("ButtonFont",Font.BOLD,15);
		mainLabelFont = new Font("MainFont",Font.BOLD,40);
		customColour = Color.blue;
		
		//center Base Panel*********************
		
		//+++general panel
		dailySumLabel = new JLabel("Total Sales");
		dailySummaryCB = new JCheckBox();
		totalRentsLabel = new JLabel("Total Stock OUT");
	    totalRentalsCB = new JCheckBox();
	    topTenRLabel = new JLabel("Top 10 Rentals");
		topTenRentalsCB = new JCheckBox();
		topTenCustLabel = new JLabel("Top 10 Customers");
		topTenCustomerCB = new JCheckBox();
		oldStockLabel = new JLabel("Old Stock Check");
		oldStockCB = new JCheckBox();
	    generalBG = new ButtonGroup();
	    generalBG.add(dailySummaryCB);
	    generalBG.add(totalRentalsCB);
	    generalBG.add(topTenRentalsCB);
		generalBG.add(topTenCustomerCB);
		generalBG.add(oldStockCB);
		generalPanel = new JPanel(new GridLayout(0,2));
		generalPanel.add(dailySumLabel);
		generalPanel.add(dailySummaryCB);
		generalPanel.add(totalRentsLabel);
		generalPanel.add(totalRentalsCB);
		generalPanel.add(topTenRLabel);
		generalPanel.add(topTenRentalsCB);
		generalPanel.add(topTenCustLabel);
		generalPanel.add(topTenCustomerCB);
		generalPanel.add(oldStockLabel);
		generalPanel.add(oldStockCB);
		generalPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue,1),"General Reports"));
		
		
		//+++DatePanel
		
		DatePanel = new JPanel();
	    toDateBut = new JButton("FROM DATE");
	    toDateBut.setPreferredSize(new Dimension(20,60));
		fromDateBut = new JButton("TO DATE");
		fromDateBut.setPreferredSize(new Dimension(20,60));
		toDateJTF = new JTextField("To Date",10);
		toDateJTF.setPreferredSize(new Dimension(20,27));
		fromDateJTF = new JTextField("From Date",10);
		fromDateJTF.setPreferredSize(new Dimension(20,27));
		DatePanel.add(toDateJTF);
		DatePanel.add(toDateBut);
		DatePanel.add(fromDateJTF);
		DatePanel.add(fromDateBut);
		DatePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue,1),"DATE RANGE"));
		
		GroupLayout layout  = new GroupLayout(DatePanel);
		layout.setAutoCreateContainerGaps(true);
		layout.setAutoCreateGaps(true);
		DatePanel.setLayout(layout);
		GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
		
		hGroup.addGroup(layout.createParallelGroup().
        addComponent(toDateJTF).addComponent(fromDateJTF));
  	    hGroup.addGroup(layout.createParallelGroup().
        addComponent(toDateBut).addComponent(fromDateBut));
   		layout.setHorizontalGroup(hGroup);
		
		GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
		vGroup.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE,true).
        addComponent(toDateJTF).addComponent(toDateBut));
   		vGroup.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE,true).
        addComponent(fromDateJTF).addComponent(fromDateBut));
        layout.setVerticalGroup(vGroup);
        
		reportChoosePanel = new JPanel(new GridLayout(0,1));
		reportChoosePanel.add(generalPanel);
		reportChoosePanel.add(DatePanel);
		
		reportJTA = new JTextArea();
		reportJTA.setRows(20);
		reportJTA.setColumns(20);
		jsp = new JScrollPane(reportJTA,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		reportPanelLabel = new JLabel("Report :");
		reportJTA.setEditable(false);
		reportPanel = new JPanel(new GridLayout(1,1));
		reportPanel.setBorder(BorderFactory.createEmptyBorder(30,30,20,0));
		//reportPanel.add(reportPanelLabel);
		reportPanel.add(jsp);
		//reportPanel.setBorder(BorderFactory.createEtchedBorder(Color.blue,Color.black));
		centerBasePanel = new JPanel(new BorderLayout());
		centerBasePanel.add(reportPanel,BorderLayout.CENTER);
		centerBasePanel.add(reportChoosePanel,BorderLayout.WEST);
		//***************************************************************
		
		//southBasePanel
		printBut = new JButton("PRINT");
		printBut.setBorder(BorderFactory.createRaisedBevelBorder());
		printBut.setFont(butFont);
		printBut.setForeground(customColour);
		displayBut = new JButton("DISPLAY");
		displayBut.setBorder(BorderFactory.createRaisedBevelBorder());
		displayBut.setFont(butFont);
		displayBut.setForeground(customColour);
		
		southBasePanel = new JPanel();
		southBasePanel.add(displayBut);
		southBasePanel.add(printBut);
		
		//northLabel
		pageLabel = new JLabel("SELECT THE OPTION CORRESPONDING TO THE REPORT NEEDED");                                                        
		pageLabel.setBorder(BorderFactory.createEtchedBorder(Color.white,Color.black));
		//pageLabel.setFont(mainLabelFont);
		pageLabel.setForeground(customColour);
		
	    //main Base Panel
		basePanel = new JPanel(new BorderLayout());
		//basePanel.add(pageLabel,BorderLayout.NORTH);
		basePanel.add(centerBasePanel);
		basePanel.add(southBasePanel,BorderLayout.SOUTH);
		basePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(Color.white,Color.blue),""));
		                    
		
		//setup This panel
		this.setLayout(new GridLayout(1,1));
		this.add(basePanel);
		
		//testFrame
		testFrame = new JFrame();
		testFrame.getContentPane();
		testFrame.add(this);
		testFrame.setSize(800,600);
		testFrame.setVisible(true);
		
		
	}//end constructor
	
	
	public static void main(String [ ] args)
	{
		new PrintReportPanel();
	}
	
}//end PrintReportPanel